namespace Vuscode.Framework.NHibernate.Conventions
{
    using FluentNHibernate.Conventions;
    using FluentNHibernate.Conventions.Instances;

    /// <summary>
    /// Defines HasMany relation convention.
    /// </summary>
    public class OneToManyConvention : IHasManyConvention
    {
        public void Apply(IOneToManyCollectionInstance instance)
        {
            instance.Cascade.AllDeleteOrphan();
            instance.Key.ForeignKey(string.Format("{0}ID", instance.Member.DeclaringType.Name));
        }
    }
}